cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(hello-world LANGUAGES CXX)

# 设置 C++ 标准 (可选，但推荐)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set( USE_LIBRARY OFF)
message(STATUS "Compile sources into a library? ${USE_LIBRARY}")

set(BUILD_SHARED_LIBS OFF)

list(APPEND _sources include/message.hpp src/message.cpp)

foreach(WORD hello world cmake)
	message("this is: ${WORD}")
endforeach()
# 添加包含目录，以便编译器能够找到 message.hpp
# include_directories(${CMAKE_SOURCE_DIR}/include)
if (USE_LIBRARY)
  # 创建一个静态库 (或动态库)
  add_library(message ${_sources})
  add_executable(hello-world helloWorld.cpp)
  target_link_libraries(hello-world message)
else()
  # 创建一个可执行文件
  add_executable(hello-world helloWorld.cpp ${_sources})
endif()
